﻿using System.Collections.Generic;

namespace Beeflys.Generator
{
    public sealed class Mapper
    {
        private Dictionary<string, IType> mapper = new Dictionary<string, IType>();

        public List<IType> GetTypes()
        {
            return new List<IType>(mapper.Values);
        }


        public void Add(IType type)
        {
            if (this.mapper.ContainsKey(type.FullName))
            {
                return;
            }
            
            this.mapper.Add(type.FullName, type);
        }

        public void Add(List<IType> list)
        {
            foreach (var item in list)
            {
                this.Add(item);
            }
        }


        public bool Contains(string fullName)
        {
            return this.mapper.ContainsKey(fullName);
        }

        public IType Get(string fullName)
        {
            if (this.mapper.ContainsKey(fullName))
            {
                return this.mapper[fullName];
            }

            return null;
        }
    }
}